<?php
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
   $fecha1 = $_REQUEST['capass2']."00:00:00";
    $fecha2 = $_REQUEST['capass22']."23:59:59";
    
    $f1 = date('Y-m-d',strtotime($fecha1));
    $f2 = date('Y-m-d',strtotime($fecha2));
    
    $indi = "select case when ate_analgesia = 'si' then 'Pacientes que se le aplico analgesia obstetrica' end as analge,analg.total 
            from atenMaterna
                    outer apply(select COUNT(distinct adnIngreso) as total 
                                            from atenMaterna
                                            where ate_analgesia = 'si' and ate_fecha between '".$f1."' and '".$f2."')as analg
            where ate_analgesia = 'si'
            group by ate_analgesia,analg.total 
            union
            select case when ate_analgesia = 'no' then 'Pacientes que no se le aplico analgesia obstetrica' end as analge,analg.total 
            from atenMaterna
                    outer apply(select COUNT(distinct adnIngreso) as total 
                                            from atenMaterna
                                            where ate_analgesia = 'no' and ate_fecha between '".$f1."' and '".$f2."')as analg
            where ate_analgesia = 'no'
            group by ate_analgesia,analg.total";
    $lsti = $con->query($indi);
    while($res = mssql_fetch_array($lsti)){
        $lst[] = $res;
    }
    $con->cerrarConexion();
    print_r(json_encode($lst));

?>